﻿@model EnetaMvc.Web.Models.BlogDetailsModel
@using System.Configuration
@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_NewsLayout.cshtml";
}

<div class="blog-head">
    <div class="user-foto"> <a href="@Url.Content("~/profiles/details/" + Model.Blog.CreatedById)"><img alt="@Model.Blog.CreatedByUserName" src="@Html.GetProfileUrl(Model.Blog.CreatedById, 64)" width="64" height="64" /></a> </div>
	<div class="blog-head-txt">
		<h2><a href="@Url.Content("~/news/blogs/details/" + Model.Blog.Id)">@Model.Blog.Name</a></h2>
        <div class="blog-head-main"> <span>@Resources.EnetaMvc.BlogFirstPost: @Model.Blog.FirstPostDate.ToShortDateString()</span>
			<p>@Html.Raw(Model.Blog.Description)</p>
		</div>
        <div class="blog-panel">
			<ul>
				<li class="user"><a href="@Url.Content("~/profiles/details/" + Model.Blog.CreatedById)">@Model.Blog.CreatedByUserName</a></li>
				<li class="site"><a href="@Model.Blog.Url">@Model.Blog.Url</a></li>
				<li class="link-rss"><a href="@Model.Blog.RssUrl">RSS</a></li>
			</ul>
		</div>
	</div>
</div>

<div class="content-blog-area">
	@for (var i = 0; i < Model.Posts.Results.Count; i++)
    {
        if (i == 5)
        {
            break;
        }
        var article = Model.Posts.Results[i];
        var firstArticleSuffix = (Model.Posts.CurrentPage == 1 && i == 0 ? "blog-first" : "");
        var commentsCountString = new MvcHtmlString("");

        if (article.Comments.Length != 0)
        {
            commentsCountString = new MvcHtmlString("<span>(" + article.Comments.Length + ")</span>");
        }
     
	<div class="blog @firstArticleSuffix">
		<div class="blog-foto"> <a href="@Url.Content("~/Profiles/Details/" + article.CreatedById)"><img alt="@article.CreatedByUserName" src="@Html.GetProfileUrl(article.CreatedById)" width="32" height="32" /></a> </div>
		<div class="blog-txt">
			<h3><a href="@Url.Content("~/news/blogs/posts/details/" + article.Id)">@article.Title @commentsCountString</a></h3>
			<ul>
				<li><a href="@Url.Content("~/Profiles/Details/" + article.CreatedById)"><strong>@article.CreatedByUserName</strong></a></li>
                <li><a href="@Url.Content("~/news/blogs/details/" + article.BlogId)">@article.BlogName</a></li>
				<li>@article.Created.ToShortDateString()</li>
			</ul>
			<p>@Html.Raw(article.Abstract) <a class="more-info" href="@Url.Content("~/news/blogs/posts/details/" + article.Id)">@Resources.EnetaMvc.ReadMore</a></p>
			@*<ul class="tags">
				<li><a href="#">äri</a>,</li>
				<li><a href="#">ettevõtlus</a>,</li>
				<li><a href="#">sündmus</a>,</li>
				<li><a href="#">haridus</a>,</li>
				<li><a href="#">BizTalk</a></li>
			</ul>*@
		</div>
	</div>
    }
</div>

@if(Model.Posts.Results.Count > 5)
{
    <div class="post-list">
        <ul>
            @for(var i=5;  i<Model.Posts.Results.Count; i++)
            {
                var post = Model.Posts.Results[i];
	            <li>
                    <span>@post.Created.ToShortDateString()</span>
                    <a href="@Url.Content("~/news/blogs/posts/details/" + post.Id)">@post.Title</a>
	            </li>
            }
        </ul>
    </div>
}

<div class="blogs-menu">
	<ul>
		<li><a href="@Url.Content("~/")">@ConfigurationManager.AppSettings["PortalName"]</a></li>
        <li>@Resources.EnetaMvc.News</li>
        <li><a href="@Url.Content("~/news/blogs/posts/")">@Resources.EnetaMvc.Blogs</a></li>
        <li> <a href="@Url.Content("~/news/blogs/details/" + Model.Blog.Id)"> <img alt="@Model.Blog.CreatedByUserName" src="@Html.GetProfileUrl(Model.Blog.CreatedById, 16)" width="16" height="16" /> <span>@Model.Blog.Name</span> </a> </li>	
	</ul>
    @Html.GetPager(Model.Posts, Url.Content("~/news/blogs/details/" + Model.Blog.Id + "/"))
</div>

